<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /**
         * 调用takeMutation()方法可以清空记录队列，取出并返回所有的MutatoinRecord实例
        */

        const mutationobserver = new MutationObserver((mutationrecord) => {
            // console.log(mutationobserver)
        })

        mutationobserver.observe(document.body, {
            attributes: true
        })

        document.body.className = 'redmi'
        document.body.className = 'xiaomi'
        document.body.className = 'apple'

        console.log(mutationobserver.takeRecords()) // [Mutation,Mutation,Mutation]
        console.log(mutationobserver.takeRecords()) // []
    </script>
</body>
</html>